home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / frasrc19.zip / FRASETUP.C < prev    next >
C/C++ Source or Header  |  1995-01-29  |  32KB  |  1,121 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <float.h>
  4. #include <limits.h>
  5. #include <string.h>
  6. #ifdef __TURBOC__
  7. #include <alloc.h>
  8. #elif !defined(__386BSD__)
  9. #include <malloc.h>
  10. #endif
  11. #include "fractint.h"
  12. #include "mpmath.h"
  13. #include "helpdefs.h"
  14. #include "fractype.h"
  15. #include "prototyp.h"
  16.  
  17. #ifndef XFRACT
  18. #define MPCmod(m) (*pMPadd(*pMPmul((m).x, (m).x), *pMPmul((m).y, (m).y)))
  19. #endif
  20.  
  21. /* -------------------------------------------------------------------- */
  22. /*        Setup (once per fractal image) routines         */
  23. /* -------------------------------------------------------------------- */
  24.  
  25. MandelSetup()        /* Mandelbrot Routine */
  26. {
  27.    if (debugflag != 90 && ! invert && decomp[0] == 0 && rqlim <= 4.0
  28.        && bitshift == 29 && potflag == 0
  29.        && biomorph == -1 && inside > -59 && outside >= -1
  30.        && useinitorbit != 1 && using_jiim == 0 && bailoutest == Mod)
  31.       calctype = calcmand; /* the normal case - use CALCMAND */
  32.    else
  33.    {
  34.       /* special case: use the main processing loop */
  35.       calctype = StandardFractal;
  36.       longparm = &linit;
  37.    }
  38.    return(1);
  39. }
  40.  
  41. JuliaSetup()        /* Julia Routine */
  42. {
  43.    if (debugflag != 90 && ! invert && decomp[0] == 0 && rqlim <= 4.0
  44.        && bitshift == 29 && potflag == 0
  45.        && biomorph == -1 && inside > -59 && outside >= -1
  46.        && !finattract && using_jiim == 0 && bailoutest == Mod)
  47.       calctype = calcmand; /* the normal case - use CALCMAND */
  48.    else
  49.    {
  50.       /* special case: use the main processing loop */
  51.       calctype = StandardFractal;
  52.       longparm = &lparm;
  53.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  54.    }
  55.    return(1);
  56. }
  57.  
  58. NewtonSetup()        /* Newton/NewtBasin Routines */
  59. {
  60.    int i;
  61.    if (debugflag != 1010)
  62.    {
  63.       if(fpu != 0)
  64.       {
  65.      if(fractype == MPNEWTON)
  66.         fractype = NEWTON;
  67.      else if(fractype == MPNEWTBASIN)
  68.         fractype = NEWTBASIN;
  69.       }
  70.       else
  71.       {
  72.      if(fractype == NEWTON)
  73.            fractype = MPNEWTON;
  74.      else if(fractype == NEWTBASIN)
  75.            fractype = MPNEWTBASIN;
  76.       }
  77.       curfractalspecific = &fractalspecific[fractype];
  78.    }
  79.  
  80.    /* set up table of roots of 1 along unit circle */
  81.    degree = (int)parm.x;
  82.    if(degree < 2)
  83.       degree = 3;   /* defaults to 3, but 2 is possible */
  84.    root = 1;
  85.  
  86.    /* precalculated values */
  87.    roverd    = (double)root / (double)degree;
  88.    d1overd    = (double)(degree - 1) / (double)degree;
  89.    maxcolor    = 0;
  90.    threshold    = .3*PI/degree; /* less than half distance between roots */
  91. #ifndef XFRACT
  92.    if (fractype == MPNEWTON || fractype == MPNEWTBASIN) {
  93.       mproverd       = *pd2MP(roverd);
  94.       mpd1overd    = *pd2MP(d1overd);
  95.       mpthreshold  = *pd2MP(threshold);
  96.       mpone       = *pd2MP(1.0);
  97.    }
  98. #endif
  99.  
  100.    floatmin = FLT_MIN;
  101.    floatmax = FLT_MAX;
  102.  
  103.    basin = 0;
  104.    if(roots != staticroots) {
  105.       free(roots);
  106.       roots = staticroots;
  107.    }
  108.  
  109.    if (fractype==NEWTBASIN)
  110.    {
  111.       if(parm.y)
  112.      basin = 2; /*stripes */
  113.       else
  114.      basin = 1;
  115.       if(degree > 16)
  116.       {
  117.      if((roots=(_CMPLX *)malloc(degree*sizeof(_CMPLX)))==NULL)
  118.      {
  119.         roots = staticroots;
  120.         degree = 16;
  121.      }
  122.       }
  123.       else
  124.      roots = staticroots;
  125.  
  126.       /* list of roots to discover where we converged for newtbasin */
  127.       for(i=0;i<degree;i++)
  128.       {
  129.      roots[i].x = cos(i*twopi/(double)degree);
  130.      roots[i].y = sin(i*twopi/(double)degree);
  131.       }
  132.    }
  133. #ifndef XFRACT
  134.    else if (fractype==MPNEWTBASIN)
  135.    {
  136.      if(parm.y)
  137.      basin = 2; /*stripes */
  138.       else
  139.      basin = 1;
  140.  
  141.       if(degree > 16)
  142.       {
  143.      if((MPCroots=(struct MPC *)malloc(degree*sizeof(struct MPC)))==NULL)
  144.      {
  145.         MPCroots = (struct MPC *)staticroots;
  146.         degree = 16;
  147.      }
  148.       }
  149.       else
  150.      MPCroots = (struct MPC *)staticroots;
  151.  
  152.       /* list of roots to discover where we converged for newtbasin */
  153.       for(i=0;i<degree;i++)
  154.       {
  155.      MPCroots[i].x = *pd2MP(cos(i*twopi/(double)degree));
  156.      MPCroots[i].y = *pd2MP(sin(i*twopi/(double)degree));
  157.       }
  158.    }
  159. #endif
  160.  
  161.    param[0] = (double)degree; /* JCO 7/1/92 */
  162.    if (degree%4 == 0)
  163.       symmetry = XYAXIS;
  164.    else
  165.       symmetry = XAXIS;
  166.  
  167.    calctype=StandardFractal;
  168. #ifndef XFRACT
  169.    if (fractype == MPNEWTON || fractype == MPNEWTBASIN)
  170.       setMPfunctions();
  171. #endif
  172.    return(1);
  173. }
  174.  
  175.  
  176. StandaloneSetup()
  177. {
  178.    timer(0,curfractalspecific->calctype);
  179.    return(0);        /* effectively disable solid-guessing */
  180. }
  181.  
  182. UnitySetup()
  183. {
  184.    periodicitycheck = 0;
  185.    FgOne = (1L << bitshift);
  186.    FgTwo = FgOne + FgOne;
  187.    return(1);
  188. }
  189.  
  190. MandelfpSetup()
  191. {
  192.    bf_math = 0;
  193.    c_exp = (int)param[2];
  194.    pwr.x = param[2] - 1.0;
  195.    pwr.y = param[3];
  196.    floatparm = &init;
  197.    switch (fractype)
  198.    {
  199.    case MARKSMANDELFP:
  200.       if(c_exp < 1){
  201.          c_exp = 1;
  202.          param[2] = 1;
  203.       }
  204.       if(!(c_exp & 1))
  205.          symmetry = XYAXIS_NOPARM;    /* odd exponents */
  206.       if(c_exp & 1)
  207.          symmetry = XAXIS_NOPARM;
  208.       break;
  209.    case MANDELFP:
  210.     /*
  211.        floating point code could probably be altered to handle many of
  212.        the situations that otherwise are using StandardFractal().
  213.        calcmandfp() can currently handle invert, any rqlim, potflag
  214.        zmag, epsilon cross, and all the current outside options
  215.                              Wes Loewer 11/03/91
  216.     */
  217.     if (debugflag != 90
  218.         && !distest
  219.         && decomp[0] == 0
  220.         && biomorph == -1
  221.         && (inside >= -1 || inside == -59 || inside == -100)
  222.         /* uncomment this next line if more outside options are added */
  223.         /* && outside >= -5 */
  224.         && useinitorbit != 1
  225.         && using_jiim == 0 && bailoutest == Mod)
  226.     {
  227.        calctype = calcmandfp; /* the normal case - use calcmandfp */
  228.        calcmandfpasmstart();
  229.     }
  230.     else
  231.     {
  232.        /* special case: use the main processing loop */
  233.        calctype = StandardFractal;
  234.     }
  235.     break;
  236.    case FPMANDELZPOWER:
  237.       if((double)c_exp == param[2] && (c_exp & 1)) /* odd exponents */
  238.          symmetry = XYAXIS_NOPARM;
  239.       if(param[3] != 0)
  240.          symmetry = NOSYM;
  241.       if(param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  242.           fractalspecific[fractype].orbitcalc = floatZpowerFractal;
  243.       else
  244.           fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal;
  245.       break;
  246.    case MAGNET1M:
  247.    case MAGNET2M:
  248.       attr[0].x = 1.0;        /* 1.0 + 0.0i always attracts */
  249.       attr[0].y = 0.0;        /* - both MAGNET1 and MAGNET2 */
  250.       attrperiod[0] = 1;
  251.       attractors = 1;
  252.       break;
  253.    case SPIDERFP:
  254.       if(periodicitycheck==1) /* if not user set */
  255.      periodicitycheck=4;
  256.       break;
  257.    case MANDELEXP:
  258.       symmetry = XAXIS_NOPARM;
  259.       break;
  260. /* Added to account for symmetry in manfn+exp and manfn+zsqrd */
  261. /*     JCO 2/29/92 */
  262.    case FPMANTRIGPLUSEXP:
  263.    case FPMANTRIGPLUSZSQRD:
  264.      if(parm.y == 0.0)
  265.         symmetry = XAXIS;
  266.      else
  267.         symmetry = NOSYM;
  268.      if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */
  269.         symmetry = NOSYM;
  270.       break;
  271.    case QUATFP:
  272.       floatparm = &tmp;
  273.       attractors = 0;
  274.       periodicitycheck = 0;
  275.       break;
  276.    case HYPERCMPLXFP:
  277.       floatparm = &tmp;
  278.       attractors = 0;
  279.       periodicitycheck = 0;
  280.       if(trigndx[0] == 14) /* FLIP */
  281.         symmetry = NOSYM;
  282.       break;
  283.    case TIMSERRORFP:
  284.       if(trigndx[0] == 14) /* FLIP */
  285.         symmetry = NOSYM;
  286.       break;
  287.    case MARKSMANDELPWRFP:
  288.       if(trigndx[0] == 14) /* FLIP */
  289.         symmetry = NOSYM;
  290.       break;
  291.    default:
  292.       break;
  293.    }
  294.    return(1);
  295. }
  296.  
  297. JuliafpSetup()
  298. {
  299.    c_exp = (int)param[2];
  300.    floatparm = &parm;
  301.    if(fractype==COMPLEXMARKSJUL)
  302.    {
  303.       pwr.x = param[2] - 1.0;
  304.       pwr.y = param[3];
  305.       coefficient = ComplexPower(*floatparm, pwr);
  306.    }
  307.    switch (fractype)
  308.    {
  309.    case JULIAFP:
  310.     /*
  311.        floating point code could probably be altered to handle many of
  312.        the situations that otherwise are using StandardFractal().
  313.        calcmandfp() can currently handle invert, any rqlim, potflag
  314.        zmag, epsilon cross, and all the current outside options
  315.                              Wes Loewer 11/03/91
  316.     */
  317.     if (debugflag != 90
  318.         && !distest
  319.         && decomp[0] == 0
  320.         && biomorph == -1
  321.         && (inside >= -1 || inside == -59 || inside == -100)
  322.         /* uncomment this next line if more outside options are added */
  323.         /* && outside >= -5 */
  324.         && useinitorbit != 1
  325.         && !finattract
  326.         && using_jiim == 0 && bailoutest == Mod)
  327.     {
  328.        calctype = calcmandfp; /* the normal case - use calcmandfp */
  329.        calcmandfpasmstart();
  330.     }
  331.     else
  332.     {
  333.        /* special case: use the main processing loop */
  334.        calctype = StandardFractal;
  335.        get_julia_attractor (0.0, 0.0);   /* another attractor? */
  336.     }
  337.     break;
  338.    case FPJULIAZPOWER:
  339.       if((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2] )
  340.          symmetry = NOSYM;
  341.       if(param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  342.           fractalspecific[fractype].orbitcalc = floatZpowerFractal;
  343.       else
  344.           fractalspecific[fractype].orbitcalc = floatCmplxZpowerFractal;
  345.       get_julia_attractor (param[0], param[1]);    /* another attractor? */
  346.       break;
  347.    case MAGNET2J:
  348.       FloatPreCalcMagnet2();
  349.    case MAGNET1J:
  350.       attr[0].x = 1.0;        /* 1.0 + 0.0i always attracts */
  351.       attr[0].y = 0.0;        /* - both MAGNET1 and MAGNET2 */
  352.       attrperiod[0] = 1;
  353.       attractors = 1;
  354.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  355.       break;
  356.    case LAMBDAFP:
  357.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  358.       get_julia_attractor (0.5, 0.0);    /* another attractor? */
  359.       break;
  360.    case LAMBDAEXP:
  361.       if(parm.y == 0.0)
  362.      symmetry=XAXIS;
  363.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  364.       break;
  365. /* Added to account for symmetry in julfn+exp and julfn+zsqrd */
  366. /*     JCO 2/29/92 */
  367.    case FPJULTRIGPLUSEXP:
  368.    case FPJULTRIGPLUSZSQRD:
  369.      if(parm.y == 0.0)
  370.         symmetry = XAXIS;
  371.      else
  372.         symmetry = NOSYM;
  373.      if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */
  374.         symmetry = NOSYM;
  375.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  376.       break;
  377.    case HYPERCMPLXJFP:
  378.       if(trigndx[0] != SQR)
  379.          symmetry=NOSYM;
  380.    case QUATJULFP:
  381.       attractors = 0;    /* attractors broken since code checks r,i not j,k */
  382.       periodicitycheck = 0;
  383.       if(param[4] != 0.0 || param[5] != 0)
  384.          symmetry = NOSYM;
  385.       break;
  386.    default:
  387.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  388.       break;
  389.    }
  390.    return(1);
  391. }
  392.  
  393. MandellongSetup()
  394. {
  395.    FgHalf = fudge >> 1;
  396.    c_exp = (int)param[2];
  397.    if(fractype==MARKSMANDEL && c_exp < 1){
  398.       c_exp = 1;
  399.       param[2] = 1;
  400.    }
  401.    if((fractype==MARKSMANDEL   && !(c_exp & 1)) ||
  402.        (fractype==LMANDELZPOWER && (c_exp & 1)))
  403.       symmetry = XYAXIS_NOPARM;    /* odd exponents */
  404.    if((fractype==MARKSMANDEL && (c_exp & 1)) || fractype==LMANDELEXP)
  405.       symmetry = XAXIS_NOPARM;
  406.    if(fractype==SPIDER && periodicitycheck==1)
  407.       periodicitycheck=4;
  408.    longparm = &linit;
  409.    if(fractype==LMANDELZPOWER)
  410.    {
  411.       if(param[3] == 0.0 && debugflag != 6000  && (double)c_exp == param[2])
  412.           fractalspecific[fractype].orbitcalc = longZpowerFractal;
  413.       else
  414.           fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal;
  415.       if(param[3] != 0 || (double)c_exp != param[2] )
  416.          symmetry = NOSYM;
  417.     }
  418. /* Added to account for symmetry in manfn+exp and manfn+zsqrd */
  419. /*     JCO 2/29/92 */
  420.    if((fractype==LMANTRIGPLUSEXP)||(fractype==LMANTRIGPLUSZSQRD))
  421.    {
  422.      if(parm.y == 0.0)
  423.         symmetry = XAXIS;
  424.      else
  425.         symmetry = NOSYM;
  426.      if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */
  427.         symmetry = NOSYM;
  428.    }
  429.    if(fractype == TIMSERROR)
  430.    {
  431.      if(trigndx[0] == 14) /* FLIP */
  432.         symmetry = NOSYM;
  433.     }
  434.    if(fractype == MARKSMANDELPWR)
  435.    {
  436.      if(trigndx[0] == 14) /* FLIP */
  437.         symmetry = NOSYM;
  438.     }
  439.    return(1);
  440. }
  441.  
  442. JulialongSetup()
  443. {
  444.    c_exp = (int)param[2];
  445.    longparm = &lparm;
  446.    switch (fractype)
  447.    {
  448.    case LJULIAZPOWER:
  449.       if((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2])
  450.          symmetry = NOSYM;
  451.       if(param[3] == 0.0 && debugflag != 6000 && (double)c_exp == param[2])
  452.           fractalspecific[fractype].orbitcalc = longZpowerFractal;
  453.       else
  454.           fractalspecific[fractype].orbitcalc = longCmplxZpowerFractal;
  455.       break;
  456.    case LAMBDA:
  457.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  458.       get_julia_attractor (0.5, 0.0);    /* another attractor? */
  459.       break;
  460.    case LLAMBDAEXP:
  461.       if(lparm.y == 0)
  462.      symmetry = XAXIS;
  463.       break;
  464. /* Added to account for symmetry in julfn+exp and julfn+zsqrd */
  465. /*     JCO 2/29/92 */
  466.    case LJULTRIGPLUSEXP:
  467.    case LJULTRIGPLUSZSQRD:
  468.      if(parm.y == 0.0)
  469.         symmetry = XAXIS;
  470.      else
  471.         symmetry = NOSYM;
  472.      if ((trigndx[0] == LOG) || (trigndx[0] == 14)) /* LOG or FLIP */
  473.         symmetry = NOSYM;
  474.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  475.       break;
  476.    default:
  477.       get_julia_attractor (0.0, 0.0);    /* another attractor? */
  478.       break;
  479.    }
  480.    return(1);
  481. }
  482.  
  483. TrigPlusSqrlongSetup()
  484. {
  485.    curfractalspecific->per_pixel =  julia_per_pixel;
  486.    curfractalspecific->orbitcalc =  TrigPlusSqrFractal;
  487.    if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  488.    {
  489.       if(lparm2.x == fudge)       /* Scott variant */
  490.      curfractalspecific->orbitcalc =  ScottTrigPlusSqrFractal;
  491.       else if(lparm2.x == -fudge)  /* Skinner variant */
  492.      curfractalspecific->orbitcalc =  SkinnerTrigSubSqrFractal;
  493.    }
  494.    return(JulialongSetup());
  495. }
  496.  
  497. TrigPlusSqrfpSetup()
  498. {
  499.    curfractalspecific->per_pixel =  juliafp_per_pixel;
  500.    curfractalspecific->orbitcalc =  TrigPlusSqrfpFractal;
  501.    if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  502.    {
  503.       if(parm2.x == 1.0)    /* Scott variant */
  504.      curfractalspecific->orbitcalc =  ScottTrigPlusSqrfpFractal;
  505.       else if(parm2.x == -1.0)    /* Skinner variant */
  506.      curfractalspecific->orbitcalc =  SkinnerTrigSubSqrfpFractal;
  507.    }
  508.    return(JuliafpSetup());
  509. }
  510.  
  511. TrigPlusTriglongSetup()
  512. {
  513.    FnPlusFnSym();
  514.    if(trigndx[1] == SQR)
  515.       return(TrigPlusSqrlongSetup());
  516.    curfractalspecific->per_pixel =  long_julia_per_pixel;
  517.    curfractalspecific->orbitcalc =  TrigPlusTrigFractal;
  518.    if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  519.    {
  520.       if(lparm2.x == fudge)       /* Scott variant */
  521.      curfractalspecific->orbitcalc =  ScottTrigPlusTrigFractal;
  522.       else if(lparm2.x == -fudge)  /* Skinner variant */
  523.      curfractalspecific->orbitcalc =  SkinnerTrigSubTrigFractal;
  524.    }
  525.    return(JulialongSetup());
  526. }
  527.  
  528. TrigPlusTrigfpSetup()
  529. {
  530.    FnPlusFnSym();
  531.    if(trigndx[1] == SQR)
  532.       return(TrigPlusSqrfpSetup());
  533.    curfractalspecific->per_pixel =  otherjuliafp_per_pixel;
  534.    curfractalspecific->orbitcalc =  TrigPlusTrigfpFractal;
  535.    if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  536.    {
  537.       if(parm2.x == 1.0)    /* Scott variant */
  538.      curfractalspecific->orbitcalc =  ScottTrigPlusTrigfpFractal;
  539.       else if(parm2.x == -1.0)    /* Skinner variant */
  540.      curfractalspecific->orbitcalc =  SkinnerTrigSubTrigfpFractal;
  541.    }
  542.    return(JuliafpSetup());
  543. }
  544.  
  545. FnPlusFnSym() /* set symmetry matrix for fn+fn type */
  546. {
  547.    static char far fnplusfn[7][7] =
  548.    {/* fn2 ->sin     cos    sinh    cosh   exp    log    sqr  */
  549.    /* fn1 */
  550.    /* sin */ {PI_SYM,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  551.    /* cos */ {XAXIS, PI_SYM,XAXIS,  XYAXIS,XAXIS, XAXIS, XAXIS},
  552.    /* sinh*/ {XYAXIS,XAXIS, XYAXIS, XAXIS, XAXIS, XAXIS, XAXIS},
  553.    /* cosh*/ {XAXIS, XYAXIS,XAXIS,  XYAXIS,XAXIS, XAXIS, XAXIS},
  554.    /* exp */ {XAXIS, XYAXIS,XAXIS,  XAXIS, XYAXIS,XAXIS, XAXIS},
  555.    /* log */ {XAXIS, XAXIS, XAXIS,  XAXIS, XAXIS, XAXIS, XAXIS},
  556.    /* sqr */ {XAXIS, XAXIS, XAXIS,  XAXIS, XAXIS, XAXIS, XYAXIS}
  557.    };
  558.    if(parm.y == 0.0 && parm2.y == 0.0)
  559.     { if(trigndx[0] < 7 && trigndx[1] < 7)  /* bounds of array JCO 5/6/92*/
  560.         symmetry = fnplusfn[trigndx[0]][trigndx[1]];  /* JCO 5/6/92 */
  561.       if(trigndx[0] == 14 || trigndx[1] == 14) /* FLIP */
  562.         symmetry = NOSYM;
  563.     }                 /* defaults to XAXIS symmetry JCO 5/6/92 */
  564.    else
  565.       symmetry = NOSYM;
  566.    return(0);
  567. }
  568.  
  569. LambdaTrigOrTrigSetup()
  570. {
  571. /* default symmetry is ORIGIN  JCO 2/29/92 (changed from PI_SYM) */
  572.    longparm = &lparm; /* added to consolidate code 10/1/92 JCO */
  573.    floatparm = &parm;
  574.    if ((trigndx[0] == EXP) || (trigndx[1] == EXP))
  575.       symmetry = NOSYM; /* JCO 1/9/93 */
  576.    if ((trigndx[0] == LOG) || (trigndx[1] == LOG))
  577.       symmetry = XAXIS;
  578.    get_julia_attractor (0.0, 0.0);    /* an attractor? */
  579.    return(1);
  580. }
  581.  
  582. JuliaTrigOrTrigSetup()
  583. {
  584. /* default symmetry is XAXIS */
  585.    longparm = &lparm; /* added to consolidate code 10/1/92 JCO */
  586.    floatparm = &parm;
  587.    if(parm.y != 0.0)
  588.      symmetry = NOSYM;
  589.    if(trigndx[0] == 14 || trigndx[1] == 14) /* FLIP */
  590.      symmetry = NOSYM;
  591.    get_julia_attractor (0.0, 0.0);    /* an attractor? */
  592.    return(1);
  593. }
  594.  
  595. ManlamTrigOrTrigSetup()
  596. { /* psuedo */
  597. /* default symmetry is XAXIS */
  598.    longparm = &linit; /* added to consolidate code 10/1/92 JCO */
  599.    floatparm = &init;
  600.    if (trigndx[0] == SQR)
  601.       symmetry = NOSYM;
  602.    if ((trigndx[0] == LOG) || (trigndx[1] == LOG))
  603.       symmetry = NOSYM;
  604.    return(1);
  605. }
  606.  
  607. MandelTrigOrTrigSetup()
  608. {
  609. /* default symmetry is XAXIS_NOPARM */
  610.    longparm = &linit; /* added to consolidate code 10/1/92 JCO */
  611.    floatparm = &init;
  612.    if ((trigndx[0] == 14) || (trigndx[1] == 14)) /* FLIP  JCO 5/28/92 */
  613.       symmetry = NOSYM;
  614.    return(1);
  615. }
  616.  
  617.  
  618. ZXTrigPlusZSetup()
  619. {
  620. /*   static char far ZXTrigPlusZSym1[] = */
  621.    /* fn1 ->  sin   cos    sinh  cosh exp   log   sqr */
  622. /*         {XAXIS,XYAXIS,XAXIS,XYAXIS,XAXIS,NOSYM,XYAXIS}; */
  623. /*   static char far ZXTrigPlusZSym2[] = */
  624.    /* fn1 ->  sin   cos    sinh  cosh exp   log   sqr */
  625. /*         {NOSYM,ORIGIN,NOSYM,ORIGIN,NOSYM,NOSYM,ORIGIN}; */
  626.  
  627.    if(param[1] == 0.0 && param[3] == 0.0)
  628. /*      symmetry = ZXTrigPlusZSym1[trigndx[0]]; */
  629.    switch(trigndx[0])
  630.    {
  631.       case COS:   /* changed to two case statments and made any added */
  632.       case COSH:  /* functions default to XAXIS symmetry. JCO 5/25/92 */
  633.       case SQR:
  634.       case 9:   /* 'real' cos */
  635.          symmetry = XYAXIS;
  636.          break;
  637.       case 14:   /* FLIP  JCO 2/29/92 */
  638.          symmetry = YAXIS;
  639.          break;
  640.       case LOG:
  641.          symmetry = NOSYM;
  642.          break;
  643.       default:
  644.          symmetry = XAXIS;
  645.          break;
  646.       }
  647.    else
  648. /*      symmetry = ZXTrigPlusZSym2[trigndx[0]]; */
  649.    switch(trigndx[0])
  650.    {
  651.       case COS:
  652.       case COSH:
  653.       case SQR:
  654.       case 9:   /* 'real' cos */
  655.          symmetry = ORIGIN;
  656.          break;
  657.       case 14:   /* FLIP  JCO 2/29/92 */
  658.          symmetry = NOSYM;
  659.          break;
  660.       default:
  661.          symmetry = NOSYM;
  662.          break;
  663.       }
  664.    if(curfractalspecific->isinteger)
  665.    {
  666.       curfractalspecific->orbitcalc =  ZXTrigPlusZFractal;
  667.       if(lparm.x == fudge && lparm.y == 0L && lparm2.y == 0L && debugflag != 90)
  668.       {
  669.      if(lparm2.x == fudge)       /* Scott variant */
  670.          curfractalspecific->orbitcalc =  ScottZXTrigPlusZFractal;
  671.      else if(lparm2.x == -fudge)  /* Skinner variant */
  672.          curfractalspecific->orbitcalc =  SkinnerZXTrigSubZFractal;
  673.       }
  674.       return(JulialongSetup());
  675.    }
  676.    else
  677.    {
  678.       curfractalspecific->orbitcalc =  ZXTrigPlusZfpFractal;
  679.       if(parm.x == 1.0 && parm.y == 0.0 && parm2.y == 0.0 && debugflag != 90)
  680.       {
  681.      if(parm2.x == 1.0)    /* Scott variant */
  682.          curfractalspecific->orbitcalc =  ScottZXTrigPlusZfpFractal;
  683.      else if(parm2.x == -1.0)    /* Skinner variant */
  684.          curfractalspecific->orbitcalc =  SkinnerZXTrigSubZfpFractal;
  685.       }
  686.    }
  687.    return(JuliafpSetup());
  688. }
  689.  
  690. LambdaTrigSetup()
  691. {
  692.    int isinteger;
  693.    if((isinteger = curfractalspecific->isinteger) != 0)
  694.       curfractalspecific->orbitcalc =  LambdaTrigFractal;
  695.    else
  696.       curfractalspecific->orbitcalc =  LambdaTrigfpFractal;
  697.    switch(trigndx[0])
  698.    {
  699.    case SIN:
  700.    case COS:
  701.    case 9:   /* 'real' cos, added this and default for additional functions */
  702.       symmetry = PI_SYM;
  703.       if(isinteger)
  704.      curfractalspecific->orbitcalc =  LambdaTrigFractal1;
  705.       else
  706.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal1;
  707.       break;
  708.    case SINH:
  709.    case COSH:
  710.       symmetry = ORIGIN;
  711.       if(isinteger)
  712.      curfractalspecific->orbitcalc =  LambdaTrigFractal2;
  713.       else
  714.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal2;
  715.       break;
  716.    case SQR:
  717.       symmetry = ORIGIN;
  718.       break;
  719.    case EXP:
  720.       if(isinteger)
  721.      curfractalspecific->orbitcalc =  LongLambdaexponentFractal;
  722.       else
  723.      curfractalspecific->orbitcalc =  LambdaexponentFractal;
  724.       symmetry = NOSYM; /* JCO 1/9/93 */
  725.       break;
  726.    case LOG:
  727.       symmetry = NOSYM;
  728.       break;
  729.    default:   /* default for additional functions */
  730.       symmetry = ORIGIN;  /* JCO 5/8/92 */
  731.       break;
  732.    }
  733.    get_julia_attractor (0.0, 0.0);    /* an attractor? */
  734.    if(isinteger)
  735.       return(JulialongSetup());
  736.    else
  737.       return(JuliafpSetup());
  738. }
  739.  
  740. JuliafnPlusZsqrdSetup()
  741. {
  742. /*   static char far fnpluszsqrd[] = */
  743.    /* fn1 ->  sin   cos    sinh  cosh    sqr    exp   log  */
  744.    /* sin    {NOSYM,ORIGIN,NOSYM,ORIGIN,ORIGIN,NOSYM,NOSYM}; */
  745.  
  746. /*   symmetry = fnpluszsqrd[trigndx[0]];   JCO  5/8/92 */
  747.    switch(trigndx[0]) /* fix sqr symmetry & add additional functions */
  748.    {
  749.    case COS: /* cosxx */
  750.    case COSH:
  751.    case SQR:
  752.    case 9:   /* 'real' cos */
  753.    case 10:  /* tan */
  754.    case 11:  /* tanh */
  755.    symmetry = ORIGIN;
  756.     /* default is for NOSYM symmetry */
  757.    }
  758.    if(curfractalspecific->isinteger)
  759.       return(JulialongSetup());
  760.    else
  761.       return(JuliafpSetup());
  762. }
  763.  
  764. SqrTrigSetup()
  765. {
  766. /*   static char far SqrTrigSym[] = */
  767.    /* fn1 ->  sin    cos    sinh   cosh   sqr     exp   log  */
  768. /*         {PI_SYM,PI_SYM,XYAXIS,XYAXIS,XYAXIS,XAXIS,XAXIS}; */
  769. /*   symmetry = SqrTrigSym[trigndx[0]];      JCO  5/9/92 */
  770.    switch(trigndx[0]) /* fix sqr symmetry & add additional functions */
  771.    {
  772.    case SIN:
  773.    case COS: /* cosxx */
  774.    case 9:   /* 'real' cos */
  775.    symmetry = PI_SYM;
  776.     /* default is for XAXIS symmetry */
  777.    }
  778.    if(curfractalspecific->isinteger)
  779.       return(JulialongSetup());
  780.    else
  781.       return(JuliafpSetup());
  782. }
  783.  
  784. FnXFnSetup()
  785. {
  786.    static char far fnxfn[7][7] =
  787.    {/* fn2 ->sin     cos    sinh    cosh  exp    log    sqr */
  788.    /* fn1 */
  789.    /* sin */ {PI_SYM,YAXIS, XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS},
  790.    /* cos */ {YAXIS, PI_SYM,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS},
  791.    /* sinh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS},
  792.    /* cosh*/ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XAXIS, NOSYM, XYAXIS},
  793.    /* exp */ {XAXIS, XAXIS, XAXIS, XAXIS, XAXIS, NOSYM, XYAXIS},
  794.    /* log */ {NOSYM, NOSYM, NOSYM, NOSYM, NOSYM, XAXIS, NOSYM},
  795.    /* sqr */ {XYAXIS,XYAXIS,XYAXIS,XYAXIS,XYAXIS,NOSYM, XYAXIS},
  796.    };
  797.    /*
  798.    if(trigndx[0]==EXP || trigndx[0]==LOG || trigndx[1]==EXP || trigndx[1]==LOG)
  799.       symmetry = XAXIS;
  800.    else if((trigndx[0]==SIN && trigndx[1]==SIN)||(trigndx[0]==COS && trigndx[1]==COS))
  801.       symmetry = PI_SYM;
  802.    else if((trigndx[0]==SIN && trigndx[1]==COS)||(trigndx[0]==COS && trigndx[1]==SIN))
  803.       symmetry = YAXIS;
  804.    else
  805.       symmetry = XYAXIS;
  806.    */
  807.    if(trigndx[0] < 7 && trigndx[1] < 7)  /* bounds of array JCO 5/22/92*/
  808.         symmetry = fnxfn[trigndx[0]][trigndx[1]];  /* JCO 5/22/92 */
  809.                     /* defaults to XAXIS symmetry JCO 5/22/92 */
  810.    else {  /* added to complete the symmetry JCO 5/22/92 */
  811.       if (trigndx[0]==LOG || trigndx[1] ==LOG) symmetry = NOSYM;
  812.       if (trigndx[0]==9 || trigndx[1] ==9) { /* 'real' cos */
  813.          if (trigndx[0]==SIN || trigndx[1] ==SIN) symmetry = PI_SYM;
  814.          if (trigndx[0]==COS || trigndx[1] ==COS) symmetry = PI_SYM;
  815.       }
  816.       if (trigndx[0]==9 && trigndx[1] ==9) symmetry = PI_SYM;
  817.    }
  818.    if(curfractalspecific->isinteger)
  819.       return(JulialongSetup());
  820.    else
  821.       return(JuliafpSetup());
  822. }
  823.  
  824. MandelTrigSetup()
  825. {
  826.    int isinteger;
  827.    if((isinteger = curfractalspecific->isinteger) != 0)
  828.       curfractalspecific->orbitcalc =  LambdaTrigFractal;
  829.    else
  830.       curfractalspecific->orbitcalc =  LambdaTrigfpFractal;
  831.    symmetry = XYAXIS_NOPARM;
  832.    switch(trigndx[0])
  833.    {
  834.    case SIN:
  835.    case COS:
  836.       if(isinteger)
  837.      curfractalspecific->orbitcalc =  LambdaTrigFractal1;
  838.       else
  839.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal1;
  840.       break;
  841.    case SINH:
  842.    case COSH:
  843.       if(isinteger)
  844.      curfractalspecific->orbitcalc =  LambdaTrigFractal2;
  845.       else
  846.      curfractalspecific->orbitcalc =  LambdaTrigfpFractal2;
  847.       break;
  848.    case EXP:
  849.       symmetry = XAXIS_NOPARM;
  850.       if(isinteger)
  851.      curfractalspecific->orbitcalc =  LongLambdaexponentFractal;
  852.       else
  853.      curfractalspecific->orbitcalc =  LambdaexponentFractal;
  854.       break;
  855.    case LOG:
  856.       symmetry = XAXIS_NOPARM;
  857.       break;
  858.    default:   /* added for additional functions, JCO 5/25/92 */
  859.       symmetry = XYAXIS_NOPARM;
  860.       break;
  861.    }
  862.    if(isinteger)
  863.       return(MandellongSetup());
  864.    else
  865.       return(MandelfpSetup());
  866. }
  867.  
  868. MarksJuliaSetup()
  869. {
  870.    if(param[2] < 1)
  871.       param[2] = 1;
  872.    c_exp = (int)param[2];
  873.    longparm = &lparm;
  874.    lold = *longparm;
  875.    if(c_exp > 3)
  876.       lcpower(&lold,c_exp-1,&lcoefficient,bitshift);
  877.    else if(c_exp == 3)
  878.    {
  879.       lcoefficient.x = multiply(lold.x,lold.x,bitshift) - multiply(lold.y,lold.y,bitshift);
  880.       lcoefficient.y = multiply(lold.x,lold.y,bitshiftless1);
  881.    }
  882.    else if(c_exp == 2)
  883.       lcoefficient = lold;
  884.    else if(c_exp < 2) {
  885.       lcoefficient.x = 1L << bitshift;
  886.       lcoefficient.y = 0L;
  887.    }
  888.    get_julia_attractor (0.0, 0.0);    /* an attractor? */
  889.    return(1);
  890. }
  891.  
  892. MarksJuliafpSetup()
  893. {
  894.    if(param[2] < 1)
  895.       param[2] = 1;
  896.    c_exp = (int)param[2];
  897.    floatparm = &parm;
  898.    old = *floatparm;
  899.    if(c_exp > 3)
  900.       cpower(&old,c_exp-1,&coefficient);
  901.    else if(c_exp == 3)
  902.    {
  903.       coefficient.x = sqr(old.x) - sqr(old.y);
  904.       coefficient.y = old.x * old.y * 2;
  905.    }
  906.    else if(c_exp == 2)
  907.       coefficient = old;
  908.    else if(c_exp < 2) {
  909.       coefficient.x = 1.0;
  910.       coefficient.y = 0.0;
  911.    }
  912.    get_julia_attractor (0.0, 0.0);    /* an attractor? */
  913.    return(1);
  914. }
  915.  
  916. SierpinskiSetup()
  917. {
  918.    /* sierpinski */
  919.    periodicitycheck = 0;        /* disable periodicity checks */
  920.    ltmp.x = 1;
  921.    ltmp.x = ltmp.x << bitshift; /* ltmp.x = 1 */
  922.    ltmp.y = ltmp.x >> 1;            /* ltmp.y = .5 */
  923.    return(1);
  924. }
  925.  
  926. SierpinskiFPSetup()
  927. {
  928.    /* sierpinski */
  929.    periodicitycheck = 0;        /* disable periodicity checks */
  930.    tmp.x = 1;
  931.    tmp.y = 0.5;
  932.    return(1);
  933. }
  934.  
  935. HalleySetup()
  936. {
  937.    /* Halley */
  938.    periodicitycheck=0;
  939.  
  940.    if(usr_floatflag)
  941.      fractype = HALLEY; /* float on */
  942.    else
  943.      fractype = MPHALLEY;
  944.  
  945.    curfractalspecific = &fractalspecific[fractype];
  946.  
  947.    degree = (int)parm.x;
  948.    if(degree < 2)
  949.       degree = 2;
  950.    param[0] = (double)degree;
  951.  
  952. /*  precalculated values */
  953.    AplusOne = degree + 1; /* a+1 */
  954.    Ap1deg = AplusOne * degree;
  955.  
  956. #ifndef XFRACT
  957.    if(fractype == MPHALLEY) {
  958.       setMPfunctions();
  959.       mpAplusOne = *pd2MP((double)AplusOne);
  960.       mpAp1deg = *pd2MP((double)Ap1deg);
  961.       mpctmpparm.x = *pd2MP(parm.y);
  962.       mpctmpparm.y = *pd2MP(parm2.y);
  963.       mptmpparm2x = *pd2MP(parm2.x);
  964.       mpone       = *pd2MP(1.0);
  965.    }
  966. #endif
  967.  
  968.    if(degree % 2)
  969.      symmetry = XAXIS;   /* odd */
  970.    else
  971.      symmetry = XYAXIS; /* even */
  972.    return(1);
  973. }
  974.  
  975. PhoenixSetup()
  976. {
  977.    longparm = &lparm; /* added to consolidate code 10/1/92 JCO */
  978.    floatparm = &parm;
  979.    degree = (int)parm2.x;
  980.    if(degree < 2 && degree > -3) degree = 0;
  981.    param[2] = (double)degree;
  982.    if(degree == 0){
  983.      if(usr_floatflag)
  984.        curfractalspecific->orbitcalc =  PhoenixFractal;
  985.      else
  986.        curfractalspecific->orbitcalc =  LongPhoenixFractal;
  987.    }
  988.    if(degree >= 2){
  989.      degree = degree - 1;
  990.      if(usr_floatflag)
  991.        curfractalspecific->orbitcalc =  PhoenixPlusFractal;
  992.      else
  993.        curfractalspecific->orbitcalc =  LongPhoenixPlusFractal;
  994.    }
  995.    if(degree <= -3){
  996.      degree = abs(degree) - 2;
  997.      if(usr_floatflag)
  998.        curfractalspecific->orbitcalc =  PhoenixMinusFractal;
  999.      else
  1000.        curfractalspecific->orbitcalc =  LongPhoenixMinusFractal;
  1001.    }
  1002.  
  1003.    return(1);
  1004. }
  1005.  
  1006. PhoenixCplxSetup()
  1007. {
  1008.    longparm = &lparm;
  1009.    floatparm = &parm;
  1010.    degree = (int)param[4];
  1011.    if(degree < 2 && degree > -3) degree = 0;
  1012.    param[4] = (double)degree;
  1013.    if(degree == 0){
  1014.      if(parm2.x != 0 || parm2.y != 0)
  1015.        symmetry = NOSYM;
  1016.      else
  1017.        symmetry = ORIGIN;
  1018.      if(parm.y == 0 && parm2.y == 0)
  1019.        symmetry = XAXIS;
  1020.      if(usr_floatflag)
  1021.        curfractalspecific->orbitcalc =  PhoenixFractalcplx;
  1022.      else
  1023.        curfractalspecific->orbitcalc =  LongPhoenixFractalcplx;
  1024.    }
  1025.    if(degree >= 2){
  1026.      degree = degree - 1;
  1027.      if(parm.y == 0 && parm2.y == 0)
  1028.        symmetry = XAXIS;
  1029.      else
  1030.        symmetry = NOSYM;
  1031.      if(usr_floatflag)
  1032.        curfractalspecific->orbitcalc =  PhoenixCplxPlusFractal;
  1033.      else
  1034.        curfractalspecific->orbitcalc =  LongPhoenixCplxPlusFractal;
  1035.    }
  1036.    if(degree <= -3){
  1037.      degree = abs(degree) - 2;
  1038.      if(parm.y == 0 && parm2.y == 0)
  1039.        symmetry = XAXIS;
  1040.      else
  1041.        symmetry = NOSYM;
  1042.      if(usr_floatflag)
  1043.        curfractalspecific->orbitcalc =  PhoenixCplxMinusFractal;
  1044.      else
  1045.        curfractalspecific->orbitcalc =  LongPhoenixCplxMinusFractal;
  1046.    }
  1047.  
  1048.    return(1);
  1049. }
  1050.  
  1051. MandPhoenixSetup()
  1052. {
  1053.    longparm = &linit; /* added to consolidate code 10/1/92 JCO */
  1054.    floatparm = &init;
  1055.    degree = (int)parm2.x;
  1056.    if(degree < 2 && degree > -3) degree = 0;
  1057.    param[2] = (double)degree;
  1058.    if(degree == 0){
  1059.      if(usr_floatflag)
  1060.        curfractalspecific->orbitcalc =  PhoenixFractal;
  1061.      else
  1062.        curfractalspecific->orbitcalc =  LongPhoenixFractal;
  1063.    }
  1064.    if(degree >= 2){
  1065.      degree = degree - 1;
  1066.      if(usr_floatflag)
  1067.        curfractalspecific->orbitcalc =  PhoenixPlusFractal;
  1068.      else
  1069.        curfractalspecific->orbitcalc =  LongPhoenixPlusFractal;
  1070.    }
  1071.    if(degree <= -3){
  1072.      degree = abs(degree) - 2;
  1073.      if(usr_floatflag)
  1074.        curfractalspecific->orbitcalc =  PhoenixMinusFractal;
  1075.      else
  1076.        curfractalspecific->orbitcalc =  LongPhoenixMinusFractal;
  1077.    }
  1078.  
  1079.    return(1);
  1080. }
  1081.  
  1082. MandPhoenixCplxSetup()
  1083. {
  1084.    longparm = &linit; /* added to consolidate code 10/1/92 JCO */
  1085.    floatparm = &init;
  1086.    degree = (int)param[4];
  1087.    if(degree < 2 && degree > -3) degree = 0;
  1088.    param[4] = (double)degree;
  1089.    if(parm.y != 0 || parm2.y != 0)
  1090.      symmetry = NOSYM;
  1091.    if(degree == 0){
  1092.      if(usr_floatflag)
  1093.        curfractalspecific->orbitcalc =  PhoenixFractalcplx;
  1094.      else
  1095.        curfractalspecific->orbitcalc =  LongPhoenixFractalcplx;
  1096.    }
  1097.    if(degree >= 2){
  1098.      degree = degree - 1;
  1099.      if(usr_floatflag)
  1100.        curfractalspecific->orbitcalc =  PhoenixCplxPlusFractal;
  1101.      else
  1102.        curfractalspecific->orbitcalc =  LongPhoenixCplxPlusFractal;
  1103.    }
  1104.    if(degree <= -3){
  1105.      degree = abs(degree) - 2;
  1106.      if(usr_floatflag)
  1107.        curfractalspecific->orbitcalc =  PhoenixCplxMinusFractal;
  1108.      else
  1109.        curfractalspecific->orbitcalc =  LongPhoenixCplxMinusFractal;
  1110.    }
  1111.  
  1112.    return(1);
  1113. }
  1114.  
  1115. StandardSetup()
  1116. {
  1117.    if(fractype==UNITYFP)
  1118.       periodicitycheck=0;
  1119.    return(1);
  1120. }
  1121.